<script>
import { GET_ROLES } from '@/utils/Const';
import { FactoryStore } from '@/hooks';
import { h } from 'vue';

export default {
	props : {
		permi : {
			type : Array,
			default : () => []
		}
	},
	setup (props, context) {
		const { getter } = FactoryStore({
			namespaced : 'permission',
			gettersMethod : [GET_ROLES]
		});
		return () => {
			if (props.permi.length === 0) {
				return h(context.slots.default);
			}
			return getter[GET_ROLES].value.some((v) => props.permi.includes(v))
				? h(context.slots.default)
				: null;
		};
	}
};
</script>
